<%--
  Created by IntelliJ IDEA.
  User: hua'wei
  Date: 2022/11/29
  Time: 13:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page pageEncoding="utf-8" isELIgnored="false" %>
<html>
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="style/login.css">
  <style>

  </style>
</head>

<body>

<div class="container">
  <form action="RegisterServlet" method="post" id="form" name="addForm">
    <p>欢迎注册</p>

    <div class="item">
      <img src="style/账号.svg" alt="">
      <input type="text" name="name" placeholder="账号">
    </div>
    <div class="item">
      <img src="style/密码.svg" alt="">
      <input type="password" name="password" placeholder="密码">
    </div>
    <div class="item">
      <img src="style/邮件.jpg" alt="">
      <input type="text" name="email" placeholder="邮件">
    </div>
    <p style="color: red;font-size: 12px;margin: 0">${user}</p>
    <input class="submit" type="button" value="注册" onclick="submitForm()">
    <input type="checkbox" id="checkbox">
    <div class="jur"> 已阅读并同意 <span>《用户服务协议》</span>和 <span>《隐私政策》</span></div>

    <a href="login.jsp">已有账号，去登录</a>


  </form>
</div>

</body>
<script>

  function submitForm() {
    var username = document.getElementsByName("name");
    var password = document.getElementsByName("password");
    var email = document.getElementsByName("email");
    var checkbox = document.getElementById("checkbox");

    if (username[0].value == "") {
      alert("请填写账号！");
      addForm.username.focus();
      return
    }
    if (password[0].value == "") {
      alert("请输入密码！");
      addForm.password.focus();
      return
    }
    if (email[0].value == "") {
      alert("请输入邮箱！");
      addForm.password.focus();
      return
    }
    if (checkbox.checked == false) {
      alert("请勾选协议");
      return
    }

    document.getElementById("form").submit();

  }
  
</script>

</html>
